<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
  <script src="../js/vue.js"></script>
</head>

<body>
  <div id ="app"> 
    <!-- 类用数组表示,加单引号是固定的，不加是变量。使用较少 -->
    <!-- <h2 class="title" :class="[active, 'line']">{{ message }}</h2> -->
    
    <!-- 如果class比较复杂可以用方法表示--> -->
    <h2 class="title" :class="getClass()">{{ message }}</h2>
  </div>

  <script>
   var vm = new Vue({
    el: '#app',
    data: {
      message: "你好啊",
      active: "aaa",
      line: "bbb"
    },
    methods: {
      getClass: function() {
        return [this.active, 'line'];
      }
    }
   });
  </script>
</body>

</html>